package com.situ.yB2C;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.situ.yB2C.util.ContextUtil;

/**
 * Application Lifecycle Listener implementation class MyServletContextListener
 *
 */
@WebListener
public class MyServletContextListener implements ServletContextListener {
	private static final Logger LOG = LoggerFactory.getLogger(MyServletContextListener.class );
    /**
     * Default constructor. 
     */
    public MyServletContextListener() {
        LOG.debug("这是applcation的监听器，随着项目的启动而启动");
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     * #当applcation对象（SevletContext）生成的时候会自动调用方法
     */
    public void contextDestroyed(ServletContextEvent sce)  { 
         
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent servletContextEvent)  { 
    	ServletContext  application  = servletContextEvent.getServletContext();
        String realPath =  application.getRealPath("/");
        LOG.debug("项目的根路径=" + realPath);
        //ContextUtil.realPath = realPath;
    }
	
}
